using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace Fcdbas.Core
{
	[System.Diagnostics.DebuggerDisplay("{Value}")]
	[System.Serializable]
	public class SalString : System.IComparable, System.IConvertible, System.IFormattable, INullable, ISalType
	{
		private class DateTimeFormatFixer
		{
			private string m_format;
			private System.Globalization.CultureInfo m_culture;
			internal DateTimeFormatFixer(string format, System.Globalization.CultureInfo culture)
			{
				this.m_format = format;
				this.m_culture = ((culture == null) ? System.Globalization.CultureInfo.CurrentCulture : culture);
			}
			internal string FixText(string text)
			{
				System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
				string format = this.m_format;
				int num = 0;
				int num2 = 0;
				while (true)
				{
					string text2 = this.GetNextDatePart(text, num);
					bool flag = false;
					string nextFormatPart = this.GetNextFormatPart(format, num2, out flag);
					if (nextFormatPart.Length == 0)
					{
						break;
					}
					num += text2.Length;
					num2 += nextFormatPart.Length;
					if (flag)
					{
						if (nextFormatPart.Length > 0 && nextFormatPart.Length > text2.Length)
						{
							char c = nextFormatPart[0];
							if (c == 'Y' || c == 'y')
							{
								if (text2.Length == 0)
								{
									text2 = System.DateTime.Now.Year.ToString();
									goto IL_15B;
								}
								try
								{
									text2 = this.m_culture.Calendar.ToFourDigitYear(int.Parse(text2)).ToString();
									goto IL_15B;
								}
								catch (System.FormatException)
								{
									goto IL_15B;
								}
							}
							text2 = text2.PadLeft(nextFormatPart.Length, '0');
						}
					}
					else
					{
						text2 = text2.Trim();
						if (text2.Length == 0)
						{
							string a;
							if ((a = nextFormatPart.Trim()) != null)
							{
								if (a == "t")
								{
									text2 = " a";
									goto IL_15B;
								}
								if (a == "tt")
								{
									text2 = " am";
									goto IL_15B;
								}
							}
							text2 = nextFormatPart;
						}
						else
						{
							if (text2.Length == 1 && char.IsPunctuation(text2, 0))
							{
								text2 = nextFormatPart;
							}
						}
					}
					IL_15B:
					stringBuilder.Append(text2);
				}
				stringBuilder.Append(text.Substring(num));
				return stringBuilder.ToString();
			}
			private string GetNextDatePart(string text, int start)
			{
				bool flag = true;
				bool flag2 = false;
				for (int i = start; i < text.Length; i++)
				{
					char c = text[i];
					if (flag)
					{
						flag = false;
						flag2 = (!char.IsWhiteSpace(c) && !char.IsPunctuation(c));
					}
					else
					{
						if (flag2 == (char.IsWhiteSpace(c) || char.IsPunctuation(c)))
						{
							return text.Substring(start, i - start);
						}
					}
				}
				return text.Substring(start);
			}
			private string GetNextFormatPart(string text, int start, out bool isFormat)
			{
				bool flag = true;
				bool flag2 = isFormat = false;
				int i = start;
				while (i < text.Length)
				{
					char c = text[i];
					if (c <= 'Y')
					{
						if (c <= 'H')
						{
							if (c != 'D' && c != 'H')
							{
								goto IL_87;
							}
							goto IL_6D;
						}
						else
						{
							if (c != 'M' && c != 'S' && c != 'Y')
							{
								goto IL_87;
							}
							goto IL_6D;
						}
					}
					else
					{
						if (c <= 'h')
						{
							if (c != 'd' && c != 'h')
							{
								goto IL_87;
							}
							goto IL_6D;
						}
						else
						{
							if (c == 'm' || c == 's' || c == 'y')
							{
								goto IL_6D;
							}
							goto IL_87;
						}
					}
					IL_A1:
					i++;
					continue;
					IL_6D:
					if (flag)
					{
						flag = false;
						flag2 = true;
						isFormat = true;
						goto IL_A1;
					}
					if (!flag2)
					{
						return text.Substring(start, i - start);
					}
					goto IL_A1;
					IL_87:
					if (flag)
					{
						flag = false;
						flag2 = false;
						isFormat = false;
						goto IL_A1;
					}
					if (flag2)
					{
						return text.Substring(start, i - start);
					}
					goto IL_A1;
				}
				return text.Substring(start);
			}
		}
		private class NumericFormatFixer
		{
			private System.Globalization.CultureInfo m_culture;
			private string m_leading = string.Empty;
			private string m_trailing = string.Empty;
			private string m_leadingNeg = string.Empty;
			private string m_trailingNeg = string.Empty;
			private bool m_hasNegativeFormat;
			internal NumericFormatFixer(string format, System.Globalization.CultureInfo culture)
			{
				this.m_culture = ((culture == null) ? System.Globalization.CultureInfo.CurrentCulture : culture);
				if (format.Length > 0)
				{
					if (format == "P" || format == "p")
					{
						switch (this.m_culture.NumberFormat.PercentPositivePattern)
						{
						case 2:
							this.m_leading = "%";
							return;
						}
						this.m_trailing = "%";
						return;
					}
					int num = 0;
					bool flag = false;
					bool flag2 = false;
					System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
					int i = 0;
					while (i < format.Length)
					{
						char c = format[i];
						char c2 = c;
						if (c2 <= '\'')
						{
							switch (c2)
							{
							case '"':
								flag2 = !flag2;
								break;
							case '#':
								goto IL_132;
							default:
								if (c2 != '\'')
								{
									goto IL_15C;
								}
								flag = !flag;
								break;
							}
						}
						else
						{
							if (c2 == '0')
							{
								goto IL_132;
							}
							if (c2 != ';')
							{
								goto IL_15C;
							}
							if (this.m_hasNegativeFormat || flag || flag2)
							{
								stringBuilder.Append(c);
							}
							else
							{
								this.SaveFormatSection(num, stringBuilder);
								this.m_hasNegativeFormat = true;
								num = 2;
							}
						}
						IL_165:
						i++;
						continue;
						IL_132:
						if (flag || flag2)
						{
							stringBuilder.Append(c);
							goto IL_165;
						}
						this.SaveFormatSection(num, stringBuilder);
						i = this.SkipFormatChars(format, i);
						num++;
						goto IL_165;
						IL_15C:
						stringBuilder.Append(c);
						goto IL_165;
					}
					this.SaveFormatSection(num, stringBuilder);
				}
			}
			private void SaveFormatSection(int section, System.Text.StringBuilder sb)
			{
				string text = sb.ToString();
				sb.Length = 0;
				switch (section)
				{
				case 0:
					this.m_leading = text;
					return;
				case 1:
					this.m_trailing = text;
					return;
				case 2:
					this.m_leadingNeg = text;
					return;
				case 3:
					this.m_trailingNeg = text;
					return;
				default:
					return;
				}
			}
			private int SkipFormatChars(string format, int start)
			{
				System.Globalization.NumberFormatInfo invariantInfo = System.Globalization.NumberFormatInfo.InvariantInfo;
				string numberGroupSeparator = invariantInfo.NumberGroupSeparator;
				string numberDecimalSeparator = invariantInfo.NumberDecimalSeparator;
				for (int i = start; i < format.Length; i++)
				{
					char c = format[i];
					char c2 = c;
					if (c2 != '#' && c2 != '0' && string.CompareOrdinal(format, i, numberGroupSeparator, 0, numberGroupSeparator.Length) != 0 && string.CompareOrdinal(format, i, numberDecimalSeparator, 0, numberDecimalSeparator.Length) != 0)
					{
						return i - 1;
					}
				}
				return format.Length;
			}
			internal string StripFormat(string text)
			{
				bool flag = !this.m_hasNegativeFormat && text.StartsWith("-");
				if (flag)
				{
					text = text.Substring(1);
				}
				if (this.m_leading.Length > 0 && text.StartsWith(this.m_leading))
				{
					text = text.Substring(this.m_leading.Length);
				}
				if (this.m_trailing.Length > 0 && text.EndsWith(this.m_trailing))
				{
					text = text.Substring(0, text.Length - this.m_trailing.Length);
				}
				if (flag)
				{
					return "-" + text.Trim();
				}
				return text.Trim();
			}
			internal string StripNegativeFormat(string text)
			{
				if (!this.m_hasNegativeFormat)
				{
					return text;
				}
				if (this.m_leadingNeg.Length > 0 && text.StartsWith(this.m_leadingNeg))
				{
					text = text.Substring(this.m_leadingNeg.Length);
				}
				if (this.m_trailingNeg.Length > 0 && text.EndsWith(this.m_trailingNeg))
				{
					text = text.Substring(0, text.Length - this.m_trailingNeg.Length);
				}
				return text.Trim();
			}
		}
		[Browsable(false), System.Diagnostics.DebuggerStepThrough, System.Obsolete("Replaced by SalArray<T>.")]
		[System.Serializable]
		public class Array : SalArray<SalString>
		{
			public Array()
			{
			}
			public Array(params int[] elems) : base(elems)
			{
			}
			public Array(params string[] elems) : base(elems)
			{
			}
			protected override object CreateInstance()
			{
				return SalString.Empty;
			}
		}
		private const string _hexDigits = "0123456789ABCDEF";
		[System.ThreadStatic]
		private static HashSet<System.IntPtr> m_validHandles;
		[System.ThreadStatic]
		private static System.Collections.Generic.Dictionary<string, System.IntPtr> m_validStrings;
		public static readonly SalString Null = new SalString((string)null);
		public static readonly SalString NullBlob = new SalString((string)null);
		public static readonly SalString Empty = new SalString(string.Empty);
		private string m_value;
		private int m_length;
		private bool m_isBlob;
		[System.NonSerialized]
		private System.Runtime.InteropServices.GCHandle m_handle;
		private static string[] m_salDateFormats = new string[]
		{
			"yyyy-M-d-H.m.s.ffffff",
			"yyyy-M-d-H:m:s:ffffff",
			"yyyy-M-d-H.m.s",
			"yyyy-M-d-H:m:s",
			"yyyy-M-d-H.m",
			"yyyy-M-d-H:m",
			"yyyy-M-d-H",
			"yyyy-M-d",
			"yyyy-M-d-H.m.s.ffffff tt",
			"yyyy-M-d-H:m:s.ffffff tt",
			"yyyy-M-d-H.m.s tt",
			"yyyy-M-d-H:m:s tt",
			"yyyy-M-d-H.m tt",
			"yyyy-M-d-H:m tt",
			"yyyy-M-d-H tt"
		};
		public SalNumber Length
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_length;
			}
		}
		public bool IsNull
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_value == null;
			}
		}
		public bool IsEmpty
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_value == null || this.m_value.Length == 0;
			}
		}
		public bool IsBlob
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_isBlob;
			}
			[System.Diagnostics.DebuggerStepThrough]
			set
			{
				this.m_isBlob = value;
			}
		}
		public string Value
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_value;
			}
		}
		public char this[int index]
		{
			[System.Diagnostics.DebuggerStepThrough]
			get
			{
				return this.m_value[index];
			}
		}
		DbType ISalType.DbType
		{
			get
			{
				if (this.IsBlob)
				{
					return DbType.Binary;
				}
				return DbType.String;
			}
		}
		object ISalType.Value
		{
			get
			{
				if (this.IsNull)
				{
					return System.DBNull.Value;
				}
				if (this.IsBlob)
				{
					return this.GetBlob();
				}
				return this.Value;
			}
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString()
		{
			this.m_length = 0;
			this.m_isBlob = false;
			this.m_value = string.Empty;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString(string x) : this()
		{
			this.m_value = x;
			this.m_isBlob = false;
			this.m_length = ((this.m_value == null) ? 0 : this.m_value.Length);
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString(char[] chars) : this()
		{
			this.m_value = new string(chars);
			this.m_isBlob = false;
			this.m_length = this.m_value.Length;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString(char[] chars, int index, int length) : this()
		{
			this.m_value = new string(chars, index, length);
			this.m_isBlob = false;
			this.m_length = this.m_value.Length;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString(byte[] blob) : this()
		{
			this.SetBlob(blob, 0, (blob == null) ? 0 : blob.Length);
		}
		[System.Diagnostics.DebuggerStepThrough]
		public SalString(byte[] blob, int index, int length) : this()
		{
			this.SetBlob(blob, index, length);
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static implicit operator SalString(string x)
		{
			return new SalString(x);
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static implicit operator SalString(System.DBNull x)
		{
			return SalString.Null;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static implicit operator string(SalString x)
		{
			if (x == (string)null)
			{
				return null;
			}
			return x.ToString();
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static implicit operator SalBoolean(SalString x)
		{
			return !x.IsEmpty;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static SalString Concat(SalString x, SalString y)
		{
			return x + y;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static SalString operator +(SalString x, SalString y)
		{
			if (x.IsEmpty)
			{
				return y;
			}
			if (y.IsEmpty)
			{
				return x;
			}
			return new SalString(x.m_value + y.m_value);
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static SalString operator +(SalString x, SalNumber y)
		{
			return x + y.ToString();
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static SalString operator +(SalNumber x, SalString y)
		{
			return x.ToString() + y;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static int Compare(SalString x, SalString y)
		{
			return string.CompareOrdinal(x, 0, y, 0, System.Math.Max(x.Length, y.Length));
		}
		[System.Diagnostics.DebuggerStepThrough]
		private static int Compare(SalString x, string y)
		{
			if (y != null)
			{
				return string.CompareOrdinal(x, 0, y, 0, System.Math.Max(x.Length, y.Length));
			}
			if (!x.IsNull)
			{
				return 1;
			}
			return 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		private static int Compare(string x, SalString y)
		{
			if (x != null)
			{
				return string.CompareOrdinal(x, 0, y, 0, System.Math.Max(x.Length, y.Length));
			}
			if (!y.IsNull)
			{
				return -1;
			}
			return 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator ==(SalString x, SalString y)
		{
			return SalString.Compare(x, y) == 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator ==(SalString x, string y)
		{
			return SalString.Compare(x, y) == 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator ==(string x, SalString y)
		{
			return SalString.Compare(x, y) == 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator !=(SalString x, SalString y)
		{
			return SalString.Compare(x, y) != 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator !=(SalString x, string y)
		{
			return SalString.Compare(x, y) != 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator !=(string x, SalString y)
		{
			return SalString.Compare(x, y) != 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >(SalString x, SalString y)
		{
			return SalString.Compare(x, y) > 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >(string x, SalString y)
		{
			return SalString.Compare(x, y) > 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >(SalString x, string y)
		{
			return SalString.Compare(x, y) > 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >=(SalString x, SalString y)
		{
			return SalString.Compare(x, y) >= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >=(string x, SalString y)
		{
			return SalString.Compare(x, y) >= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator >=(SalString x, string y)
		{
			return SalString.Compare(x, y) >= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <(SalString x, SalString y)
		{
			return SalString.Compare(x, y) < 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <(string x, SalString y)
		{
			return SalString.Compare(x, y) < 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <(SalString x, string y)
		{
			return SalString.Compare(x, y) < 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <=(SalString x, SalString y)
		{
			return SalString.Compare(x, y) <= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <=(string x, SalString y)
		{
			return SalString.Compare(x, y) <= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator <=(SalString x, string y)
		{
			return SalString.Compare(x, y) <= 0;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static implicit operator bool(SalString x)
		{
			return !x.IsEmpty;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator true(SalString x)
		{
			return !x.IsEmpty;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator false(SalString x)
		{
			return x.IsEmpty;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static bool operator !(SalString x)
		{
			return x.IsEmpty;
		}
		public override bool Equals(object obj)
		{
			if (obj is SalString)
			{
				return SalString.Compare(this, (SalString)obj) == 0;
			}
			return obj is string && SalString.Compare(this, (string)obj) == 0;
		}
		public override int GetHashCode()
		{
			if (this.IsNull)
			{
				return 0;
			}
			return this.m_value.GetHashCode();
		}
		[System.Diagnostics.DebuggerStepThrough]
		public override string ToString()
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			if (this.IsBlob)
			{
				return this.m_value.Substring(0, this.m_length);
			}
			return this.m_value;
		}
		[System.Diagnostics.DebuggerStepThrough]
		public string ToString(System.IFormatProvider provider)
		{
			return this.ToString();
		}
		[System.Diagnostics.DebuggerStepThrough]
		public string ToHex()
		{
			return this.ToHexInternal();
		}
		[System.Diagnostics.DebuggerStepThrough]
		private string ToHexInternal()
		{
			byte[] blob = this.GetBlob();
			if (blob.Length == 0)
			{
				return string.Empty;
			}
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(blob.Length * 2);
			for (int i = 0; i < blob.Length; i++)
			{
				byte b = blob[i];
				stringBuilder.Append("0123456789ABCDEF"[b >> 4]);
				stringBuilder.Append("0123456789ABCDEF"[(int)(b & 15)]);
			}
			return stringBuilder.ToString();
		}
		[System.Diagnostics.DebuggerStepThrough]
		public static SalString FromHex(string hex)
		{
			SalString result;
			try
			{
				result = SalString.FromHexInternal(hex);
			}
			catch (System.IndexOutOfRangeException)
			{
				throw new System.InvalidOperationException(Sys.GetString("InvalidHexString"));
			}
			return result;
		}
		[System.Diagnostics.DebuggerStepThrough]
		private static SalString FromHexInternal(string hex)
		{
			if (hex == null || hex.Length < 2)
			{
				return SalString.NullBlob;
			}
			int num = 0;
			if (hex.StartsWith("0x"))
			{
				num = 2;
			}
			byte[] array = new byte[(hex.Length - num) / 2];
			int num2 = 0;
			for (int i = num; i < hex.Length; i += 2)
			{
				int num3 = (int)hex[i];
				if (num3 >= 97)
				{
					num3 &= -33;
				}
				int num4 = num3 - ((num3 > 57) ? 55 : 48);
				num4 <<= 4;
				num3 = (int)hex[i + 1];
				if (num3 >= 97)
				{
					num3 &= -33;
				}
				num4 |= num3 - ((num3 > 57) ? 55 : 48);
				array[num2++] = (byte)num4;
			}
			return new SalString(array);
		}
		public System.IntPtr ToHandle()
		{
			if (this.IsNull)
			{
				return System.IntPtr.Zero;
			}
			if (SalString.m_validStrings == null)
			{
				SalString.m_validStrings = new System.Collections.Generic.Dictionary<string, System.IntPtr>();
			}
			else
			{
				if (SalString.m_validStrings.ContainsKey(this))
				{
					return SalString.m_validStrings[this];
				}
			}
			if (!this.m_handle.IsAllocated)
			{
				this.m_handle = System.Runtime.InteropServices.GCHandle.Alloc(this, System.Runtime.InteropServices.GCHandleType.Normal);
				if (SalString.m_validHandles == null)
				{
					SalString.m_validHandles = new HashSet<System.IntPtr>();
				}
				SalString.m_validHandles.Add((System.IntPtr)this.m_handle);
				SalString.m_validStrings.Add(this, (System.IntPtr)this.m_handle);
			}
			return (System.IntPtr)this.m_handle;
		}
		public static SalString FromHandle(System.IntPtr handle)
		{
			if (!(handle != System.IntPtr.Zero) || !SalString.m_validHandles.Contains(handle))
			{
				return SalString.Null;
			}
			System.Runtime.InteropServices.GCHandle gCHandle = (System.Runtime.InteropServices.GCHandle)handle;
			if (!gCHandle.IsAllocated || gCHandle.Target == null)
			{
				throw new System.InvalidOperationException("The string has been garbage collected.");
			}
			return (SalString)gCHandle.Target;
		}
		public static void FreeHandle(System.IntPtr handle)
		{
			if (handle != System.IntPtr.Zero && SalString.m_validHandles.Contains(handle))
			{
				System.Runtime.InteropServices.GCHandle gCHandle = (System.Runtime.InteropServices.GCHandle)handle;
				if (!gCHandle.IsAllocated)
				{
					throw new System.InvalidOperationException("The string has been finalized.");
				}
				SalString.m_validStrings.Remove(gCHandle.Target.ToString());
				gCHandle.Free();
				SalString.m_validHandles.Remove(handle);
			}
		}
		public byte[] GetBlob()
		{
			if (this.IsEmpty)
			{
				return new byte[0];
			}
			byte[] array = new byte[this.m_value.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = (byte)this.m_value[i];
			}
			return array;
		}
		private void SetBlob(byte[] blob, int offset, int length)
		{
			this.m_length = 0;
			this.m_value = null;
			this.m_isBlob = true;
			if (blob != null)
			{
				char[] array = new char[length];
				for (int i = offset; i < length; i++)
				{
					array[i] = (char)blob[i];
				}
				this.m_value = new string(array);
				this.m_length = this.m_value.IndexOf('\0');
				if (this.m_length < 0)
				{
					this.m_length = this.m_value.Length;
				}
			}
		}
		public SalString Clone()
		{
			return new SalString
			{
				m_value = this.m_value,
				m_isBlob = this.m_isBlob,
				m_length = this.m_length
			};
		}
		public SalString Compress()
		{
			return this.CompressInternal();
		}
		public bool Compress(ref SalString sRet)
		{
			sRet = this.CompressInternal();
			return true;
		}
		private SalString CompressInternal()
		{
			System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(this.GetBlob());
			System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(memoryStream);
			byte b = 0;
			byte b2 = 0;
			byte[] array = new byte[8];
			int num = 0;
			int num2 = 0;
			byte b3 = 0;
			System.IO.MemoryStream memoryStream2 = new System.IO.MemoryStream((int)memoryStream.Length);
			System.IO.BinaryWriter binaryWriter = new System.IO.BinaryWriter(memoryStream2);
			byte[] array2 = new byte[32768];
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i] = 32;
			}
			binaryWriter.Write(62);
			binaryWriter.Write(60);
			binaryWriter.Write(0);
			binaryWriter.Write(2);
			binaryWriter.Write(243);
			binaryWriter.Write(220);
			binaryWriter.Write((int)memoryStream.Length);
			binaryWriter.Write(0);
			try
			{
				while (memoryStream.Position < memoryStream.Length)
				{
					byte b4 = binaryReader.ReadByte();
					int num3 = (int)b << 7 ^ (int)b2;
					if (array2[num3] == b4)
					{
						b3 ^= (byte)(1 << num);
					}
					else
					{
						array2[num3] = b4;
						array[num2++] = b4;
					}
					if (++num == 8)
					{
						binaryWriter.Write(b3);
						for (int j = 0; j < num2; j++)
						{
							binaryWriter.Write(array[j]);
						}
						num = 0;
						num2 = 0;
						b3 = 0;
					}
					b = b2;
					b2 = b4;
				}
			}
			catch (System.IO.EndOfStreamException)
			{
				if (num != 0)
				{
					binaryWriter.Write(b3);
					for (int k = 0; k < num2; k++)
					{
						binaryWriter.Write(array[k]);
					}
				}
				memoryStream2.Seek(10L, System.IO.SeekOrigin.Begin);
				binaryWriter.Write((int)memoryStream2.Length);
			}
			binaryWriter.Flush();
			return new SalString(memoryStream2.ToArray());
		}
		public SalNumber GetBufferLength()
		{
			int num = this.IsNull ? 0 : this.m_value.Length;
			if (!this.IsBlob)
			{
				num++;
			}
			return num;
		}
		public bool IsValidCurrency(int precision, int scale)
		{
			return this.IsValidCurrency(precision, scale, null);
		}
		public bool IsValidCurrency(int precision, int scale, System.IFormatProvider provider)
		{
			return this.IsValidCurrency(precision, scale, null, provider);
		}
		public bool IsValidCurrency(int precision, int scale, string format, System.IFormatProvider provider)
		{
			if (this.IsEmpty)
			{
				return false;
			}
			try
			{
				decimal num = 0m;
				if (SalString.TryParse(this.m_value, format, System.Globalization.NumberStyles.Currency, provider, out num))
				{
					return SalString.CheckPrecision(num, precision, scale);
				}
			}
			catch (System.OverflowException)
			{
			}
			return false;
		}
		public bool IsValidDecimal(int precision, int scale)
		{
			return this.IsValidDecimal(precision, scale, null, null);
		}
		public bool IsValidDecimal(int precision, int scale, System.IFormatProvider provider)
		{
			return this.IsValidDecimal(precision, scale, null, provider);
		}
		public bool IsValidDecimal(int precision, int scale, string format, System.IFormatProvider provider)
		{
			if (this.IsEmpty)
			{
				return false;
			}
			try
			{
				decimal num = 0m;
				if (SalString.TryParse(this.m_value, format, System.Globalization.NumberStyles.Any, provider, out num))
				{
					return SalString.CheckPrecision(num, precision, scale);
				}
			}
			catch (System.OverflowException)
			{
			}
			return false;
		}
		public bool IsValidDateTime()
		{
			return !this.ToDate(null, null).IsNull;
		}
		public bool IsValidDateTime(System.IFormatProvider provider)
		{
			return !this.ToDate(null, provider).IsNull;
		}
		public bool IsValidDateTime(string format, System.IFormatProvider provider)
		{
			return !this.ToDate(format, provider).IsNull;
		}
		public bool IsValidNumber()
		{
			return this.IsValidNumber(null, null);
		}
		public bool IsValidNumber(System.IFormatProvider provider)
		{
			return this.IsValidNumber(null, provider);
		}
		public bool IsValidNumber(string format, System.IFormatProvider provider)
		{
			if (this.IsEmpty)
			{
				return false;
			}
			try
			{
				decimal num = 0m;
				if (SalString.TryParse(this.m_value, format, System.Globalization.NumberStyles.Any, provider, out num))
				{
					return true;
				}
			}
			catch (System.OverflowException)
			{
			}
			return false;
		}
		public bool IsValidInteger()
		{
			return this.IsValidInteger(null);
		}
		public bool IsValidInteger(string format)
		{
			if (this.IsEmpty)
			{
				return false;
			}
			try
			{
				decimal d = 0m;
				if (SalString.TryParse(this.m_value, format, System.Globalization.NumberStyles.Any, null, out d))
				{
					return d % 1m == 0m;
				}
			}
			catch (System.OverflowException)
			{
			}
			return false;
		}
		public bool IsValidIdentifierName()
		{
			if (this.IsEmpty)
			{
				return false;
			}
			for (int i = 0; i < this.m_value.Length; i++)
			{
				char c = this.m_value[i];
				if (!char.IsLetter(c) && c != '_' && (i <= 0 || !char.IsDigit(c)))
				{
					return false;
				}
			}
			return true;
		}
		public SalString Left(int length)
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			int num = this.Length;
			length = ((length > num) ? num : length);
			length = ((length < 0) ? 0 : length);
			return this.m_value.Substring(0, length);
		}
		public SalNumber Left(int length, ref SalString target)
		{
			target = this.Left(length);
			return target.Length;
		}
		public SalNumber Lop(ref SalString target)
		{
			if (this.GetBufferLength() == 0)
			{
				return -1;
			}
			if (this.IsEmpty)
			{
                target = null;// new SalString(null);
				return 0;
			}
			int x = (int)this.m_value[0];
			target = this.m_value.Substring(1);
			return x;
		}
		public static bool FirstChar(ref SalString target, ref SalNumber charCode)
		{
			int num = target.Lop(ref target);
			if (num == -1)
			{
				return false;
			}
			charCode = num;
			return true;
		}
		public SalString ToLower()
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			return this.m_value.ToLower();
		}
		public SalNumber ToLower(ref SalString target)
		{
			target = this.ToLower();
			return target.Length;
		}
		public SalString Mid(int pos, int length)
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			int num = this.Length;
			int num2 = (pos > num) ? num : pos;
			num2 = ((num2 < 0) ? 0 : num2);
			length = ((length + num2 > num) ? (num - num2) : length);
			length = ((length < 0) ? 0 : length);
			if (length == 0)
			{
				return string.Empty;
			}
			return this.m_value.Substring(num2, length);
		}
		public SalNumber Mid(int pos, int length, ref SalString target)
		{
			target = this.Mid(pos, length);
			return target.Length;
		}
		public SalString ToProper()
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			bool flag = true;
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
			int num = 0;
			while (num < this.Length)
			{
				char c = this[num];
				if (flag)
				{
					c = char.ToUpper(c);
				}
				else
				{
					c = char.ToLower(c);
				}
				stringBuilder.Append(c);
				flag = char.IsWhiteSpace(c);
				num++;
			}
			return stringBuilder.ToString();
		}
		public SalNumber ToProper(ref SalString target)
		{
			target = this.ToProper();
			return target.Length;
		}
		public SalString Repeat(int times)
		{
			if (this.IsNull || times < 1 || this.Length == 0)
			{
				return string.Empty;
			}
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(times * this.Length);
			for (int i = 0; i < times; i++)
			{
				stringBuilder.Append(this.m_value);
			}
			return stringBuilder.ToString();
		}
		public SalNumber Repeat(int times, ref SalString target)
		{
			target = this.Repeat(times);
			return target.Length;
		}
		public SalString Replace(int startPos, int length, string replace)
		{
			if (this.IsNull)
			{
				return string.Empty;
			}
			int num = this.Length;
			int num2 = (startPos >= num) ? num : startPos;
			num2 = ((num2 < 0) ? 0 : num2);
			length = ((length + num2 > num) ? (num - num2) : length);
			length = ((length < 0) ? 0 : length);
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(length);
			stringBuilder.Append(this.m_value.Substring(0, num2));
			stringBuilder.Append(replace);
			stringBuilder.Append(this.m_value.Substring(num2 + length));
			return stringBuilder.ToString();
		}
		public SalNumber Replace(int startPos, int length, string replace, ref SalString target)
		{
			target = this.Replace(startPos, length, replace);
			return target.Length;
		}
		public SalString Right(int length)
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			int num = this.Length;
			length = ((length >= num) ? num : length);
			length = ((length < 0) ? 0 : length);
			int startIndex = num - length;
			return this.m_value.Substring(startIndex, length);
		}
		public SalNumber Right(int length, ref SalString target)
		{
			target = this.Right(length);
			return target.Length;
		}
		public SalNumber Scan(string pattern)
		{
			return this.ScanInternal(pattern);
		}
		private SalNumber ScanInternal(string pattern)
		{
			if (this.IsEmpty && (pattern == null || pattern.Length == 0))
			{
				return 0;
			}
			if (this.IsEmpty || pattern == null || pattern.Length == 0)
			{
				return -1;
			}
			int i = 0;
			int num = 0;
			int length = pattern.Length;
			string value = this.m_value;
			int num2 = 0;
			int num3 = this.Length;
			int num4 = 0;
			int num5 = -1;
			bool flag = true;
			bool flag2 = false;
			while (i < length)
			{
				char c = pattern[i];
				if (c != '%')
				{
					if (c != '\\')
					{
						if (c == '_')
						{
							i++;
							num2++;
							if (num5 == -1 && num2 < num3)
							{
								num5++;
								flag = false;
								continue;
							}
							continue;
						}
					}
					else
					{
						i++;
						if (i >= length)
						{
							continue;
						}
					}
					if (flag)
					{
						flag = false;
						int num6 = value.IndexOf(char.ToUpper(pattern[i]), num2);
						int num7 = value.IndexOf(char.ToLower(pattern[i]), num2);
						int num8 = (num6 == -1) ? num7 : ((num7 == -1) ? num6 : ((num6 < num7) ? num6 : num7));
						if (num8 > -1)
						{
							i++;
							num2 = num8 + 1;
							if (num5 == -1)
							{
								num5 = num8;
							}
							if (flag2)
							{
								num4 = num2;
							}
						}
						else
						{
							if (num5 == -1 || num2 + num5 >= num3 || flag2)
							{
								return -1;
							}
							num5++;
							num2 = num5;
							i = 0;
						}
					}
					else
					{
						if (num2 >= num3)
						{
							return -1;
						}
						char c2 = char.ToUpper(value[num2]);
						char c3 = char.ToUpper(pattern[i]);
						if (c2 != c3)
						{
							if (num5 >= num3)
							{
								return -1;
							}
							if (flag2)
							{
								num2 = num4;
								i = num;
								flag = true;
							}
							else
							{
								num5++;
								i = 0;
								num2 = num5;
							}
						}
						else
						{
							num2++;
							i++;
						}
					}
				}
				else
				{
					i++;
					num = i;
					flag = true;
					flag2 = true;
					if (num5 == -1 && num2 < num3)
					{
						num5++;
					}
				}
			}
			return num5;
		}
		public SalString SetBufferLength(int length)
		{
			string text = (this.m_value == null) ? "" : this.m_value;
			if (length <= 0)
			{
				return SalString.Empty;
			}
			int num = length;
			if (this.m_value != null)
			{
				num -= text.Length;
			}
			if (num == 0)
			{
				return this;
			}
			if (num < 0)
			{
				return new SalString(text.Substring(0, length));
			}
			char[] array = new char[length];
			System.Array.Copy(text.ToCharArray(), array, text.Length);
			return new SalString(array)
			{
				m_length = text.Length
			};
		}
		public bool SetBufferLength(ref SalString target, int length)
		{
			target = this.SetBufferLength(length);
			return true;
		}
		public SalDateTime ToDate()
		{
			return this.ToDate(null, null);
		}
		public SalDateTime ToDate(string format)
		{
			return this.ToDate(format, null);
		}
		public SalDateTime ToDate(string format, System.IFormatProvider provider)
		{
			if (this.IsEmpty)
			{
				return SalDateTime.Null;
			}
			System.DateTime minValue = System.DateTime.MinValue;
			if (format != null && format.Length > 0)
			{
				if (SalString.TryParse(this.m_value, format, provider, out minValue))
				{
					return minValue;
				}
				if (format.IndexOf("yyyy") > -1)
				{
					format = format.Replace("yyyy", "yy");
					if (SalString.TryParse(this.m_value, format, provider, out minValue))
					{
						return minValue;
					}
				}
			}
			if (SalString.TryParse(this.m_value, provider, out minValue))
			{
				return minValue;
			}
			if (SalString.TryParse(this.m_value, SalString.m_salDateFormats, provider, out minValue))
			{
				return minValue;
			}
			if (SalString.TryParse(this.m_value, SalDateTime.GetDefaultLongFormat(), provider, out minValue))
			{
				return minValue;
			}
			return SalDateTime.Null;
		}
		public SalArray<SalString> Tokenize(string startDel, string endDel)
		{
			return this.TokenizeInternal(startDel, endDel);
		}
		public SalNumber Tokenize(string startDel, string endDel, SalArray<SalString> target)
		{
			SalArray<SalString> salArray = this.TokenizeInternal(startDel, endDel);
			if (salArray.Count > 0)
			{
				target.MakeDynamic();
				if (target.IsMultidimensional)
				{
					int num = target.Dimensions;
					int[] array = new int[num];
					int[] array2 = new int[num];
					int[] array3 = new int[num];
					for (int i = 0; i < num; i++)
					{
						array3[i] = target.GetUpperBound(i + 1) + 1;
						array2[i] = (array[i] = target.GetLowerBound(i + 1));
					}
					int num2 = 0;
					while (num2 < salArray.Length)
					{
						target[array] = salArray[new int[]
						{
							num2
						}];
						for (int j = num - 1; j > -1; j--)
						{
							array[j]++;
							if (j == 0 || array[j] - array2[j] < array3[j])
							{
								break;
							}
							array[j] = array2[j];
						}
						num2++;
					}
				}
				else
				{
					int num3 = target.GetLowerBound(1);
					int num4 = 0;
					while (num4 < salArray.Length)
					{
						target[new int[]
						{
							num3++
						}] = salArray[new int[]
						{
							num4
						}];
						num4++;
					}
				}
			}
			return salArray.Count;
		}
		private SalArray<SalString> TokenizeInternal(string startDel, string endDel)
		{
			SalArray<SalString> salArray = new SalArray<SalString>();
			if (this.IsEmpty)
			{
				return salArray;
			}
			int length = this.m_value.Length;
			char[] anyOf = endDel.ToCharArray();
			int num2;
			for (int i = 0; i < length; i += num2 + 1)
			{
				if (startDel.Length > 0)
				{
					while (i < length && startDel.IndexOf(this.m_value[i]) >= 0)
					{
						i++;
					}
				}
				int num = this.m_value.IndexOfAny(anyOf, i);
				string x;
				if (num < 0)
				{
					x = this.m_value.Substring(i, length - i);
					salArray.Add(new SalString(x));
					break;
				}
				num2 = num - i;
				x = this.m_value.Substring(i, num2);
				salArray.Add(new SalString(x));
			}
			return salArray;
		}
		public SalNumber ToNumber()
		{
			SalNumber result = this.ToNumber(null);
			if (result.IsNull)
			{
				return SalNumber.Zero;
			}
			return result;
		}
		public SalNumber ToNumber(string format)
		{
			return this.ToNumber(format, null);
		}
		public SalNumber ToNumber(string format, System.IFormatProvider provider)
		{
			if (this.IsEmpty)
			{
				return SalNumber.Null;
			}
			System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Any;
			decimal x = 0m;
			string text = this.m_value.Trim();
			if (format != null && format.Length > 0 && SalString.TryParse(text, format, style, provider, out x))
			{
				return x;
			}
			if (SalString.TryParse(text, style, provider, out x))
			{
				return x;
			}
			return SalNumber.Null;
		}
		public SalString Trim()
		{
			return this.TrimInternal();
		}
		public SalNumber Trim(ref SalString target)
		{
			target = this.TrimInternal();
			return target.Length;
		}
		private SalString TrimInternal()
		{
			if (this.IsEmpty)
			{
				return SalString.Empty;
			}
			bool flag = false;
			string value = this.m_value;
			System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(value.Length);
			for (int i = 0; i < value.Length; i++)
			{
				if (flag)
				{
					stringBuilder.Append(' ');
					flag = false;
				}
				char c = value[i];
				if (char.IsWhiteSpace(c) && c != '\r' && c != '\n')
				{
					flag = (stringBuilder.Length > 0);
					while (++i < value.Length)
					{
						c = value[i];
						if (!char.IsWhiteSpace(c) || c == '\r' || c == '\n')
						{
							i--;
							break;
						}
					}
				}
				else
				{
					stringBuilder.Append(c);
				}
			}
			return new SalString(stringBuilder.ToString());
		}
		public SalString Uncompress()
		{
			return this.UncompressInternal();
		}
		public bool Uncompress(ref SalString target)
		{
			target = this.UncompressInternal();
			return true;
		}
		private SalString UncompressInternal()
		{
			if (this.IsEmpty)
			{
				return SalString.Empty;
			}
			System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(this.GetBlob());
			if (memoryStream.Length < 14L)
			{
				return SalString.Empty;
			}
			System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(memoryStream);
			if (binaryReader.ReadByte() != 62 || binaryReader.ReadByte() != 60 || binaryReader.ReadByte() != 0)
			{
				return SalString.Empty;
			}
			byte b = binaryReader.ReadByte();
			if (binaryReader.ReadByte() != 243 || binaryReader.ReadByte() != 220)
			{
				return SalString.Empty;
			}
			int capacity = binaryReader.ReadInt32();
			binaryReader.ReadInt32();
			if (b == 0)
			{
				return this.m_value.Remove(0, 14);
			}
			byte b2 = 0;
			byte b3 = 0;
			byte[] array = new byte[32768];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = 32;
			}
			System.IO.MemoryStream memoryStream2 = new System.IO.MemoryStream(capacity);
			System.IO.BinaryWriter binaryWriter = new System.IO.BinaryWriter(memoryStream2);
			try
			{
				while (memoryStream.Position < memoryStream.Length)
				{
					byte b4 = binaryReader.ReadByte();
					byte b5 = b4;
					for (int j = 0; j < 8; j++)
					{
						int num = (int)b2 << 7 ^ (int)b3;
						byte b6;
						if (((int)b5 & 1 << j) != 0)
						{
							b6 = array[num];
						}
						else
						{
							b6 = binaryReader.ReadByte();
							array[num] = b6;
						}
						binaryWriter.Write(b6);
						b2 = b3;
						b3 = b6;
					}
				}
			}
			catch (System.IO.EndOfStreamException)
			{
			}
			binaryWriter.Flush();
			SalString salString = new SalString(memoryStream2.ToArray());
			if (salString.Value.Length - salString.Length <= 1)
			{
				salString = salString.ToString();
			}
			return salString;
		}
		public SalString ToUpper()
		{
			if (this.IsEmpty)
			{
				return string.Empty;
			}
			return this.m_value.ToUpper();
		}
		public SalNumber ToUpper(ref SalString target)
		{
			target = this.ToUpper();
			return target.Length;
		}
		public int CompareTo(object obj)
		{
			if (obj is SalString)
			{
				return this.CompareTo((SalString)obj);
			}
			if (this.m_value != null)
			{
				return this.m_value.CompareTo(obj);
			}
			if (obj != null)
			{
				return -1;
			}
			return 0;
		}
		public int CompareTo(SalString x)
		{
			return SalString.Compare(this, x);
		}
		System.TypeCode System.IConvertible.GetTypeCode()
		{
			return System.TypeCode.String;
		}
		ulong System.IConvertible.ToUInt64(System.IFormatProvider provider)
		{
			return this.ToNumber().ToUInt64();
		}
		sbyte System.IConvertible.ToSByte(System.IFormatProvider provider)
		{
			return this.ToNumber().ToSByte();
		}
		double System.IConvertible.ToDouble(System.IFormatProvider provider)
		{
			return this.ToNumber().ToDouble();
		}
		System.DateTime System.IConvertible.ToDateTime(System.IFormatProvider provider)
		{
			return this.ToDate();
		}
		float System.IConvertible.ToSingle(System.IFormatProvider provider)
		{
			return this.ToNumber().ToSingle();
		}
		bool System.IConvertible.ToBoolean(System.IFormatProvider provider)
		{
			return !this.IsEmpty;
		}
		int System.IConvertible.ToInt32(System.IFormatProvider provider)
		{
			return this.ToNumber().ToInt32();
		}
		ushort System.IConvertible.ToUInt16(System.IFormatProvider provider)
		{
			return this.ToNumber().ToUInt16();
		}
		short System.IConvertible.ToInt16(System.IFormatProvider provider)
		{
			return this.ToNumber().ToInt16();
		}
		byte System.IConvertible.ToByte(System.IFormatProvider provider)
		{
			return this.ToNumber().ToByte();
		}
		char System.IConvertible.ToChar(System.IFormatProvider provider)
		{
			return System.Convert.ToChar(this.m_value);
		}
		long System.IConvertible.ToInt64(System.IFormatProvider provider)
		{
			return this.ToNumber().ToInt64();
		}
		decimal System.IConvertible.ToDecimal(System.IFormatProvider provider)
		{
			return this.ToNumber().ToDecimal();
		}
		uint System.IConvertible.ToUInt32(System.IFormatProvider provider)
		{
			return this.ToNumber().ToUInt32();
		}
		object System.IConvertible.ToType(System.Type targetType, System.IFormatProvider provider)
		{
			if (targetType == typeof(SalString))
			{
				return this;
			}
			if (this.IsBlob && targetType == typeof(byte[]))
			{
				return this.GetBlob();
			}
			return ((System.IConvertible)this.m_value).ToType(targetType, provider);
		}
		string System.IFormattable.ToString(string format, System.IFormatProvider formatProvider)
		{
			return this.m_value;
		}
		private static bool TryParse(string text, System.Globalization.NumberStyles style, System.IFormatProvider provider, out decimal result)
		{
			if (text == null || text.Length == 0)
			{
				result = 0m;
				return false;
			}
			System.Globalization.NumberFormatInfo info = System.Globalization.NumberFormatInfo.CurrentInfo;
			if (provider != null)
			{
				info = (System.Globalization.NumberFormatInfo)provider.GetFormat(typeof(System.Globalization.NumberFormatInfo));
			}
			if (!SalString.CheckAndFixSeparators(ref text, info))
			{
				result = 0m;
				return false;
			}
			if (decimal.TryParse(text, style, provider, out result))
			{
				return true;
			}
			result = 0m;
			return false;
		}
		private static bool TryParse(string text, string format, System.Globalization.NumberStyles style, System.IFormatProvider provider, out decimal result)
		{
			if (text == null || text.Length == 0 || format == null || format.Length == 0)
			{
				return SalString.TryParse(text, style, provider, out result);
			}
			SalString.NumericFormatFixer numericFormatFixer = new SalString.NumericFormatFixer(format, provider as System.Globalization.CultureInfo);
			string text2 = numericFormatFixer.StripFormat(text);
			if (!SalString.TryParse(text2, style, provider, out result))
			{
				string text3 = numericFormatFixer.StripNegativeFormat(text);
				if (!SalString.TryParse(text3, style, provider, out result))
				{
					return false;
				}
				result = -result;
			}
			return true;
		}
		private static bool TryParse(string text, System.IFormatProvider provider, out System.DateTime result)
		{
			if (text == null || text.Length == 0)
			{
				result = System.DateTime.MinValue;
				return false;
			}
			bool result2;
			try
			{
				if (System.DateTime.TryParse(text, provider, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out result))
				{
					result2 = true;
				}
				else
				{
					result = System.DateTime.MinValue;
					result2 = false;
				}
			}
			catch (System.FormatException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			catch (System.ArgumentOutOfRangeException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			return result2;
		}
		private static bool TryParse(string text, string format, System.IFormatProvider provider, out System.DateTime result)
		{
			if (text == null || text.Length == 0 || format == null || format.Length == 0)
			{
				return SalString.TryParse(text, provider, out result);
			}
			bool result2;
			try
			{
				if (System.DateTime.TryParseExact(text, format, provider, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out result))
				{
					result2 = true;
				}
				else
				{
					if (format == "t" || format == "T")
					{
						if (provider == null)
						{
							provider = System.Globalization.CultureInfo.CurrentCulture;
						}
						System.Globalization.DateTimeFormatInfo dateTimeFormatInfo = (System.Globalization.DateTimeFormatInfo)provider.GetFormat(typeof(System.Globalization.DateTimeFormatInfo));
						if (format == "t")
						{
							format = dateTimeFormatInfo.ShortTimePattern;
						}
						if (format == "T")
						{
							format = dateTimeFormatInfo.LongTimePattern;
						}
					}
					SalString.DateTimeFormatFixer dateTimeFormatFixer = new SalString.DateTimeFormatFixer(format, provider as System.Globalization.CultureInfo);
					text = dateTimeFormatFixer.FixText(text);
					if (System.DateTime.TryParseExact(text, format, provider, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out result))
					{
						result2 = true;
					}
					else
					{
						result = System.DateTime.MinValue;
						result2 = false;
					}
				}
			}
			catch (System.FormatException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			catch (System.ArgumentOutOfRangeException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			return result2;
		}
		private static bool TryParse(string text, string[] formats, System.IFormatProvider provider, out System.DateTime result)
		{
			if (text == null || text.Length == 0 || formats == null || formats.Length == 0)
			{
				return SalString.TryParse(text, provider, out result);
			}
			bool result2;
			try
			{
				if (System.DateTime.TryParseExact(text, formats, provider, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out result))
				{
					result2 = true;
				}
				else
				{
					result = System.DateTime.MinValue;
					result2 = false;
				}
			}
			catch (System.FormatException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			catch (System.ArgumentOutOfRangeException)
			{
				result = System.DateTime.MinValue;
				result2 = false;
			}
			return result2;
		}
		private static bool CheckPrecision(decimal num, int precision, int scale)
		{
			num = System.Math.Abs(num);
			if (num < (decimal)System.Math.Pow(10.0, (double)(precision - scale)))
			{
				num *= (decimal)System.Math.Pow(10.0, (double)scale);
				if (num <= decimal.Floor(num))
				{
					return true;
				}
			}
			return false;
		}
		private static bool CheckAndFixSeparators(ref string text, System.Globalization.NumberFormatInfo info)
		{
			string numberGroupSeparator = info.NumberGroupSeparator;
			string numberDecimalSeparator = info.NumberDecimalSeparator;
			if (numberGroupSeparator != null && numberGroupSeparator.Length > 0)
			{
				int num = 0;
				int length = text.Length;
				int length2 = numberGroupSeparator.Length;
				int num2 = 3 + numberGroupSeparator.Length;
				while ((num = text.IndexOf(numberGroupSeparator, num)) > -1)
				{
					if (num + num2 > length || num == 0)
					{
						return false;
					}
					if (!char.IsDigit(text[num + length2]) || !char.IsDigit(text[num + length2 + 1]) || !char.IsDigit(text[num + length2 + 2]))
					{
						return false;
					}
					num += length2;
				}
				if (numberDecimalSeparator != null && numberDecimalSeparator.Length > 0 && numberGroupSeparator != "." && numberDecimalSeparator != ".")
				{
					text = text.Replace(".", numberDecimalSeparator);
				}
			}
			return true;
		}
		[EditorBrowsable(EditorBrowsableState.Never)]
		public static bool ReleaseGCHandles(out string traceMessage)
		{
			traceMessage = "";
			if (SalString.m_validHandles != null && SalString.m_validHandles.Count > 0)
			{
				foreach (System.IntPtr current in SalString.m_validHandles)
				{
					try
					{
						((System.Runtime.InteropServices.GCHandle)current).Free();
					}
					catch (System.InvalidOperationException)
					{
					}
				}
				traceMessage = string.Format("ReleaseGCHandles: {0} GCHandles were released on Explorer thread {1}", SalString.m_validHandles.Count, System.Threading.Thread.CurrentThread.ManagedThreadId);
				SalString.m_validHandles.Clear();
				SalString.m_validStrings.Clear();
				return true;
			}
			return false;
		}
	}
}
